<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.css" rel="stylesheet" media="screen">
    <!-- Custom CSS -->
    <link href="${pageContext.request.contextPath}/static/css/main.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/static/js/jquery-1.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.validate.min.js"></script>
    <script type="text/javascript">
    	$(function () {
    		 $("#registerForm").validate({
                 rules:{
                     username:{
                    	 required:true,
                    	 remote: {url: "checkUsername",
                    		 	  data : {
                    		      	username: function() {
                    		       		return $("#username").val();
                    		       			}
                    		      		}	 
                    	 		 }
                     },
                     password:{required:true},
                     passwordConfirm:{equalTo:"#password"},
                     nickname:{required:true},
                     email:{required:true}
                 },
                 messages:{
                     username:{required:"请填写用户名",remote:"用户名已被占用"},
                     password:{required:"必填"},
                     passwordConfirm :{equalTo:"两次密码输入不一致"},
                     nickname:{required:"请填写昵称"},
                     email:{required:"请填写邮箱"}
                 }
             });
		})
    </script>
</head>
<body>
<div class="container">
    <header>
        <div id="logo">
            <img src="${pageContext.request.contextPath}/static/image/logo.png"  alt="">
        </div>
        <nav class="navbar navbar-default">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse"
                        data-target="#navbar-collapse-menu">
                    <span class="sr-only">Toggle navigation</span> <span
                        class="icon-bar"></span> <span class="icon-bar"></span> <span
                        class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">首页</a>
            </div>
            <div class="collapse navbar-collapse" id="navbar-collapse-menu">
                <form action="search_result" method="get"
                      class="navbar-form navbar-left" role="search">
                    <div class="form-group">
                        <input name="title" class="form-control" placeholder="主题"
                               type="text">
                    </div>
                    <button type="submit" class="btn btn-default">搜索</button>
                </form>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="loginOut">注销</a></li>
                    <li><a>${loginUser.nickname}</a></li>
                </ul>
            </div>
        </nav>
    </header>
    <div class="content">
        <ol class="breadcrumb">
            <li><a href="#">首页</a></li>
            <li><a href="#">注册</a></li>
        </ol>
        <div class="row">
            <div class="col-md-4 col-md-offset-3">
                <form class="form-horizontal" id="registerForm" action="addUser" method="post">
                    <div class="form-group">
                        <label for="name" class="col-sm-3 control-label" >用户名</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="username" placeholder="用户名" name="username">
                            <input type="hidden" class="form-control" name="signature" value="">
                            <input type="hidden" class="form-control" name="grade" value="101">
                            <input type="hidden" class="form-control" name="id" value="0">
                            <input type="hidden" class="form-control" name="status" value="true">                            
                        </div>                   
                    </div>
                    <div class="form-group">
                        <label for="inputPassword3" class="col-sm-3 control-label">密码</label>
                        <div class="col-sm-9">
                            <input type="password" class="form-control" id="password" placeholder="密码" name="password">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="password" class="col-sm-3 control-label">密码确认</label>
                        <div class="col-sm-9">
                            <input type="password" class="form-control" id="passwordConfirm" placeholder="再次输入密码" name="passwordConfirm">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="nickname" class="col-sm-3 control-label">昵称</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="nickname" placeholder="昵称" name="nickname">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-3 control-label">Email</label>
                        <div class="col-sm-9">
                            <input type="email" class="form-control" id="email" placeholder="Email" name="email">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-9">
                            <button type="submit" class="btn btn-default">注册</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <footer id="footer" class="panel-footer">
        <p>手机论坛 xda.cn</p>
        <p>Designed by Sam Chen</p>
    </footer>
</div>
</body>
</html>